const app = require('express');
const router = app.Router();
var indexController = require("../../controllers/index.controller");
var searchController = require("../../controllers/search.controller");
var bookController = require("../../controllers/book.controller");
var registerController = require("../../controllers/register.controller");
var personalController = require('../../controllers/personal.controller');
var passwordController = require('../../controllers/password.controller');

//首页的查询请求，同级的其他文件夹也是同样的功能
router.get("/index", indexController.getIndexData);
router.get("/announcement", indexController.getOneTypeArticles);
router.get("/airport", indexController.getOneTypeArticles);
router.get("/airplain", indexController.getOneTypeArticles);
router.get("/passenger", indexController.getOneTypeArticles);
router.get("/comments", indexController.getComments);
router.post("/comments", indexController.addComment);
router.post("/commentsDislike", indexController.commentDislike);
router.post("/commentsLike", indexController.commentLike);
router.get("/articleDetail", indexController.getArticleDetail);
router.post("/articleDislike", indexController.articleDislike);
router.post("/articleLike",indexController.articleLike);

//查询预订
router.get("/search", searchController);
router.post("/travelTest", bookController.travelTest);
router.post("/book", bookController.bookFirst);
router.post("/bookTimeout", bookController.bookTimeout);
router.post("/bookPay", bookController.bookPay);
router.post("/cancelOrder", bookController.cancelOrder);

//个人中心
router.get("/historyList", personalController.getList);
router.post("/deleteOrder", personalController.deleteItem);
router.get("/personalInf", personalController.getPersonalInf);
router.post("/usernameRepeatTest", personalController.usernameRepeatTest);
router.post("/userChange", personalController.userChange);
router.post("/changePassword", personalController.changePassword);
router.get("/getDataAndInitalValues", personalController.getDataAndInitalValues);
router.get("/getUnsubscribeValues", personalController.getUnsubscribeValues);

//注册、登录、忘记密码
router.use("/login", require("./login"));
router.post("/register", registerController.registerFirst);
router.post("/rigisterSecond", registerController.rigisterSecond);
router.use("/repeatTest", registerController.repeatTest);
router.post("/password", passwordController.sendEmail);
router.post("/passwordSecond", passwordController.passwordSecond);

// router.use("/registerSecond", registerController.registerbookSecond);
// router.use("/registerThird", registerController.registerThird);

module.exports = router;